<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jstl/core"
                xmlns:sf="http://www.springframework.org/tags/faces"
                xmlns:a4j="http://richfaces.org/a4j"
                xmlns:rich="http://richfaces.org/rich"
                xmlns:spring="http://www.springframework.org/tags"
                template="../../../layout/Template.xhtml">

    <ui:define name="menu">
        <ui:include src="${user.menu}"/>
    </ui:define>

    <ui:define name="title">
        <h:outputText value="Liste des inscriptions"/>
    </ui:define>

    <ui:define name="footer">
        <h:outputText
                value="SPiJ - Universite de Marne la Vallee - Version 1.0"/>
    </ui:define>

    <ui:define name="content">
        <h:form id="listRegistration">

            <ui:fragment id="listRegistrationFragment">
                <h:messages globalOnly="true"/>

                <rich:dataTable value="#{flowScope.listRegistration}"
                                var="registrationDisplayed" border="1" cellspacing="4" width="100%"
                                id="unitDataTable" rows="10">
                    <f:facet name="header">
                        <h:outputText value="#{resourceBundle.listRegistrationFormHeader}"/>
                    </f:facet>
                    <rich:column style="text-align:center" rendered="#{not user.student}">
                        <f:facet name="header">
                            <h:outputText
                                    value="#{resourceBundle.listRegistrationFormStudent}"/>
                        </f:facet>
                        <h:outputText value="#{registrationDisplayed.student}"/>
                    </rich:column>
                    <rich:column style="text-align:center">
                        <f:facet name="header">
                            <h:outputText value="#{resourceBundle.listRegistrationFormYear}"/>
                        </f:facet>
                        <h:outputText value="#{registrationDisplayed.startTime}">
                            <f:convertDateTime pattern="yyyy - " type="time"/>
                        </h:outputText>
                        <h:outputText value="#{registrationDisplayed.endTime}">
                            <f:convertDateTime pattern="yyyy" type="time"/>
                        </h:outputText>
                    </rich:column>
                    <rich:column style="text-align:center">
                        <f:facet name="header">
                            <h:outputText value="#{resourceBundle.listRegistrationTraining}"/>
                        </f:facet>
                        <h:outputText value="#{registrationDisplayed.training}"/>
                    </rich:column>
                    <rich:column style="text-align:center">
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="#{bundle.listFormAction}">
                                    <a4j:commandButton id="listRegistrationCreateButton"
                                                       type="submit" image="/img/add.png" action="createRegistration"
                                                       styleClass="rightButton" rendered="#{not user.student}">
                                        <rich:toolTip value="#{bundle.addButton}" showDelay="600"
                                                      styleClass="tooltipButton"/>
                                    </a4j:commandButton>
                                </h:outputText>
                            </h:panelGroup>
                        </f:facet>
                        <a4j:commandButton action="validateRegistration" type="submit"
                                           image="/img/validate.png"
                                           rendered="#{user.student and not registrationDisplayed.validate}">
                            <rich:toolTip value="#{bundle.validateButton}" showDelay="600"
                                          styleClass="tooltipButton"/>
                        </a4j:commandButton>

                        <a4j:commandButton action="readRegistration" type="submit"
                                           rendered="#{not user.student and registrationDisplayed.validate}"
                                           image="/img/consult.png">
                            <rich:toolTip value="#{bundle.consultButton}" showDelay="600"
                                          styleClass="tooltipButton"/>
                        </a4j:commandButton>
                        <rich:spacer width="10%" rendered="#{not user.student and not registrationDisplayed.validate}"/>

                        <a4j:commandButton action="deleteRegistration" type="submit"
                                           image="/img/delete.png"
                                           rendered="#{not user.student and not registrationDisplayed.validate}">
                            <rich:toolTip value="#{bundle.deleteButton}" showDelay="600"
                                          styleClass="tooltipButton"/>
                        </a4j:commandButton>
                    </rich:column>
                </rich:dataTable>
            </ui:fragment>
        </h:form>
    </ui:define>
</ui:composition>